--- title: "1、握手问题" created: 2025-11-28 tags: - 算法 --- # 1、握手问题 ## 题目 握手问题 ![[image-9267bfe0.png]] ## 思路分析 ## 代码实现 ```cpp //7若是10个人 3个人没相互握手 //应该是 3*7(10-3) + ((1+6)*6)/2=42 // 14 15 16 17 18 19 110 // 24 25 26 27 28 29 210 // 34 35 36 37 38 39 310 //不存在12 13 21 23 31 //45 46 47 48 49 410 //56 57 58 59 510 //67 68 69 610 //78 79 710 //89 810 //910 //类比到50个人 7个人没相互握手 //18 19 …… 150 每行50-7=43个 //共7行 //7*43 //89 810 ……850 // …… //49 50 //首项1 尾项50-7-1=42 项数42 #include using namespace std; #define endl '\n' int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); // cout<<3*7+((1+6)*6)/2<